local matBlurEdges		= Material( "bluredges" )
local tex_MotionBlur	= render.GetMoBlurTex0()



function ResetEffects()
	
	Sharpen = 1

	MotionBlur = 0

	ColorEffects[ "$pp_colour_addr" ] 		= 0
	ColorEffects[ "$pp_colour_addg" ] 		= 0
	ColorEffects[ "$pp_colour_addb" ] 		= 0
	ColorEffects[ "$pp_colour_brightness" ] 	= 0
	ColorEffects[ "$pp_colour_contrast" ] 	= 1.0
	ColorEffects[ "$pp_colour_colour" ] 		= 1.1
	ColorEffects[ "$pp_colour_mulr" ] 		= 0
	ColorEffects[ "$pp_colour_mulg" ] 		= 1
	ColorEffects[ "$pp_colour_mulb" ] 		= 1
	
end

ResetEffects()


function FuckingIncredibleColor()
	ColorEffects[ "$pp_colour_mulr" ] 	= math.Approach( ColorEffects[ "$pp_colour_mulr" ], 0, FrameTime() * 0.3 )
	ColorEffects[ "$pp_colour_mulg" ]	= math.Approach( ColorEffects[ "$pp_colour_mulg" ], 0, FrameTime() * 0.3 )
	ColorEffects[ "$pp_colour_mulb" ] 	= math.Approach( ColorEffects[ "$pp_colour_mulb" ], 0, FrameTime() * 0.3 )
	ColorEffects[ "$pp_colour_colour" ] = math.Approach( ColorEffects[ "$pp_colour_colour" ], 1.1, FrameTime() * 0.3 )
	ColorEffects[ "$pp_colour_addr" ] 	= math.Approach( ColorEffects[ "$pp_colour_addr" ], 0.00, FrameTime() * 0.3 )
	ColorEffects[ "$pp_colour_addg" ] 	= math.Approach( ColorEffects[ "$pp_colour_addg" ], 0.00, FrameTime() * 0.3 )
	ColorEffects[ "$pp_colour_addb" ] 	= math.Approach( ColorEffects[ "$pp_colour_addb" ], 0.00, FrameTime() * 0.3 )
	ColorEffects[ "$pp_colour_brightness" ] 	= 0
	
	DrawSharp( 0, 0 )
	DrawBlur( 0, 0, 0 )
end

local function DrawColor()

	FuckingIncredibleColor();
	
	if ( LocalPlayer() and !LocalPlayer():Alive() ) then
		ColorEffects[ "$pp_colour_colour" ] 	= math.Approach( ColorEffects[ "$pp_colour_colour" ], 1, FrameTime() )
		ColorEffects[ "$pp_colour_addr" ] 	= math.Approach( ColorEffects[ "$pp_colour_addr" ], 1, FrameTime() )
		ColorEffects[ "$pp_colour_addg" ] 	= math.Approach( ColorEffects[ "$pp_colour_addg" ], 1, FrameTime() )
		ColorEffects[ "$pp_colour_addb" ] 	= math.Approach( ColorEffects[ "$pp_colour_addb" ], 1, FrameTime() )

		DrawSharp( 1, 0.25 )
		
	end
	
	DrawColorModify( ColorEffects )

end

hook.Add( "RenderScreenspaceEffects", "RenderPostProcessing", DrawColor )